<?php

namespace Home\Model;

use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class Tintuc implements InputFilterAwareInterface
{
    public $id;
    public $tieude;
    public $mota;
	public $noidung;
	public $hinhanh;
	public $ngaydang;
	public $ngaycapnhat;
	public $tacgia;
	public $hoten;
	public $linkrutgon;
	public $soluotxem;
	public $chuyenmuc;
	public $tenchuyenmuc;
	public $trangthai;
	public $tinnoibat;
	public $duongdan;

    protected $inputFilter;

    /**
     * Used by ResultSet to pass each database row to the entity
     */
    public function exchangeArray($data)
    {
        $this->id     = (isset($data['id'])) ? $data['id'] : null;
        $this->tieude = (isset($data['tieude'])) ? $data['tieude'] : null;
        $this->mota  = (isset($data['mota'])) ? $data['mota'] : null;
		$this->noidung  = (isset($data['noidung'])) ? $data['noidung'] : null;
		$this->hinhanh  = (isset($data['hinhanh'])) ? $data['hinhanh'] : null;
		$this->ngaydang  = (isset($data['ngaydang'])) ? $data['ngaydang'] : null;
		$this->ngaycapnhat  = (isset($data['ngaycapnhat'])) ? $data['ngaycapnhat'] : null;
		$this->tacgia  = (isset($data['tacgia'])) ? $data['tacgia'] : null;
		$this->hoten  = (isset($data['hoten'])) ? $data['hoten'] : null;
		$this->linkrutgon  = (isset($data['linkrutgon'])) ? $data['linkrutgon'] : null;
		$this->soluotxem  = (isset($data['soluotxem'])) ? $data['soluotxem'] : null;
		$this->chuyenmuc  = (isset($data['chuyenmuc'])) ? $data['chuyenmuc'] : null;
		$this->tenchuyenmuc  = (isset($data['tenchuyenmuc'])) ? $data['tenchuyenmuc'] : null;
		$this->trangthai  = (isset($data['trangthai'])) ? $data['trangthai'] : null;
		$this->tinnoibat  = (isset($data['tinnoibat'])) ? $data['tinnoibat'] : null;
		$this->duongdan  = (isset($data['duongdan'])) ? $data['duongdan'] : null;
    }

    public function getArrayCopy()
    {
        return get_object_vars($this);
    }

    public function setInputFilter(InputFilterInterface $inputFilter)
    {
        throw new \Exception("Not used");
    }

    public function getInputFilter()
    {
        if (!$this->inputFilter) {
            $inputFilter = new InputFilter();

            $factory = new InputFactory();

            $inputFilter->add($factory->createInput(array(
                'name'     => 'id',
                'required' => true,
                'filters'  => array(
                    array('name' => 'Int'),
                ),
            )));

            $inputFilter->add($factory->createInput(array(
                'name'     => 'tieude',
                'required' => true,
                'filters'  => array(
                    array('name' => 'StripTags'),
                    array('name' => 'StringTrim'),
                ),
                
            )));
			
			$inputFilter->add($factory->createInput(array(
                'name'     => 'mota',
                'required' => true,
                'filters'  => array(
                    array('name' => 'StripTags'),
                    array('name' => 'StringTrim'),
                ),
                
            )));
			
			$inputFilter->add($factory->createInput(array(
                'name'     => 'noidung',
                'required' => true,
                'filters'  => array(
                    array('name' => 'StripTags'),
                    array('name' => 'StringTrim'),
                ),
                
            )));
			
			$inputFilter->add(
                $factory->createInput(array(
                    'name'     => 'hinhanh',
                    'required' => true,
                ))
            );
			
			/*
            $inputFilter->add($factory->createInput(array(
                'name'     => 'password',
                'required' => true,
                'filters'  => array(
                    array('name' => 'StripTags'),
                    array('name' => 'StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name'    => 'StringLength',
                        'options' => array(
                            'encoding' => 'UTF-8',
                            'min'      => 4,
                            'max'      => 16,
							'messages' => array(
                                'stringLengthTooShort' => 'Vui lòng nhập vào từ 4-16 kí tự!', 
                                'stringLengthTooLong' => 'Vui lòng nhập vào từ 4-16 kí tự!' 
                            ),
                        ),
                    ),
                ),
            )));
			*/
			
			
			

            $this->inputFilter = $inputFilter;        
        }

        return $this->inputFilter;
    }
}
